package com.neuronrobotics.aim.robot;

import org.w3c.dom.Element;
//import org.w3c.dom.Node;
//import org.w3c.dom.NodeList;

import com.neuronrobotics.aim.robot.xml.MRIXmlFactory;

public class LinkConfiguration {
	private String name;// = getTagValue("name",eElement);
	private int index;// = Double.parseDouble(getTagValue("index",eElement));
	private double length;// = Double.parseDouble(getTagValue("length",eElement));
	private double scale;// = Double.parseDouble(getTagValue("scale",eElement));
	private double defaultOffset;// = Double.parseDouble(getTagValue("defaultOffset",eElement));
	private double upperLimit;// = Double.parseDouble(getTagValue("upperLimit",eElement));
	private double lowerLimit;// = Double.parseDouble(getTagValue("lowerLimit",eElement));
	private boolean inverted;
	
	private double k[] = new double[3];
	
	public LinkConfiguration(Element eElement){
    	setName(MRIXmlFactory.getTagValue("name",eElement));
    	setIndex(Integer.parseInt(MRIXmlFactory.getTagValue("index",eElement)));
    	setLength(Double.parseDouble(MRIXmlFactory.getTagValue("length",eElement)));
    	setScale(Double.parseDouble(MRIXmlFactory.getTagValue("scale",eElement)));
    	setDefaultOffset(Double.parseDouble(MRIXmlFactory.getTagValue("defaultOffset",eElement)));
    	setUpperLimit(Double.parseDouble(MRIXmlFactory.getTagValue("upperLimit",eElement)));
    	setLowerLimit(Double.parseDouble(MRIXmlFactory.getTagValue("lowerLimit",eElement)));
    	k[0]=Double.parseDouble(MRIXmlFactory.getTagValue("pGain",eElement));
    	k[1]=Double.parseDouble(MRIXmlFactory.getTagValue("iGain",eElement));
    	k[2]=Double.parseDouble(MRIXmlFactory.getTagValue("dGain",eElement));
    	inverted=MRIXmlFactory.getTagValue("isInverted",eElement).contains("true");
    	System.out.println(inverted);
	}
	public String toString(){
		String s="Name: "+name+", index: "+index;
		return s;
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public int getIndex() {
		return index;
	}
	public void setLength(double length) {
		this.length = length;
	}
	public double getLength() {
		return length;
	}
	public void setScale(double scale) {
		this.scale = scale;
	}
	public double getScale() {
		return scale;
	}
	public void setDefaultOffset(double defaultOffset) {
		this.defaultOffset = defaultOffset;
	}
	public double getDefaultOffset() {
		return defaultOffset;
	}
	public void setUpperLimit(double upperLimit) {
		this.upperLimit = upperLimit;
	}
	public double getUpperLimit() {
		return upperLimit;
	}
	public void setLowerLimit(double lowerLimit) {
		this.lowerLimit = lowerLimit;
	}
	public double getLowerLimit() {
		return lowerLimit;
	}
	public double getKP() {
		return k[0];
	}
	public double getKI() {
		return k[1];
	}
	public double getKD() {
		return k[2];
	}
	public void setInverted(boolean inverted) {
		this.inverted = inverted;
	}
	public boolean isInverted() {
		return inverted;
	}
	
}
